<include file="Public/min-header"/>

<script type="text/javascript">
    window.UEDITOR_Admin_URL = "__ROOT__/Public/plugins/Ueditor/";
    var URL_upload = "{$URL_upload}";
    var URL_fileUp = "{$URL_fileUp}";
    var URL_scrawlUp = "{$URL_scrawlUp}";
    var URL_getRemoteImage = "{$URL_getRemoteImage}";
    var URL_imageManager = "{$URL_imageManager}";
    var URL_imageUp = "{$URL_imageUp}";
    var URL_getMovie = "{$URL_getMovie}";
    var URL_home = "{$URL_home}";
</script>

<load href="__ROOT__/Public/plugins/Ueditor/ueditor.config.js"/>
<load href="__ROOT__/Public/plugins/Ueditor/ueditor.all.js"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<style>
.select{
  float:right;
}
.personsp{
  display: none;
  position:relative;
  z-index: 19;
  background: white;
}
.personul{
}
.personsp:hover{
  background: #333;
}
</style>

<div class="tab_ul">
  <h4>{$first_column_name[0]['name']}/{$second_column_name[0]['name']}/{$third_column_name}</h4>
  <ul class="nav nav-tabs" role="tablist">
    <li class="active" onclick="tab_active(-1)"><a href="#">总览</a></li>
    <foreach name="fourth_column" item="v" key="k">
      <li onclick="tab_active({$k})"><a href="#">{$v.name}</a></li>
    </foreach>
  </ul>
</div>

<div class="wrapper">
  <section class="content">
     <div class="row">
      <div class="col-md-12">
        <div class="box box-info">
          <div class="box-header with-border">
            <h3 class="box-title">总览</h3>
          </div>
          <div class="total">
            <ul style="padding:60px;">
              <foreach name="fourth_column" item="v" key="k">
                <li style="list-style:none;">
                  <a href="/index.php/Admin/Overseas/articleList?fourth_column_id={$v[id]}">
                    <div class="info-box">
                      <span class="info-box-icon bg-aqua"><i class="fa fa-files-o"></i></span>
                      <div class="info-box-content">
                        <span class="info-box-text">{$v.name}</span>
                        <span class="info-box-number">
                          <?php
                            $i = 0;
                          ?>
                          <foreach name="article_total" item="vv" key="kk">
                            <?php
                              if($vv['fourth_column_id'] == $v['id']){
                                $i+=1;
                              }
                            ?>
                          </foreach>
                          <?php
                            echo $i."&nbsp;&nbsp;篇文章";
                          ?>
                        </span>
                      </div>
                    </div>
                  </a>
                </li>
              </foreach>
            </ul>
          </div>
        </div>
      </div>
     </div>
  </section>
</div>

<foreach name="fourth_column" item="v" key="k">

  <div class="wrapper tomeoutnone">
     	<section class="content">
         <div class="row">
  			<div class="col-md-12">

  			<div class="box box-info">
                  <div class="box-header with-border">
                    <h3 class="box-title">发布文章/{$v.name}</h3>
                  </div>
                  <form class="form-horizontal" action="{:U('Overseas/articleHandle')}" id="add_post{$k}" method="post">
                    <div class="box-body">
                      <div class="form-group">
                         <label class="col-sm-2 control-label">省份</label>
                         <div class="col-sm-2">
                           	<!-- <select class="small form-control" name="province_id">
                           		<option value="0">全国</option>
                              <foreach name="province" item="vv" key="kk">
                                <option value="{$vv.id}" onclick="get_city{$k}({$vv.id})">{$vv.name}</option>
                              </foreach>
                           	</select> -->
                            <ul class="small form-control personul" name="province_id" >
                              <li class="select">▽</li><input type="hidden" value="0" name="province_id" id="province{$k}"/>
                           		<li class="personqg personqg{$k} personno personno{$k}" value="0">全国</li>
                              <foreach name="province" item="vv" key="kk">
                                <li style="list-style:none;width:120px;" class="personsp personno personno{$k}"  onclick="get_city{$k}({$vv.id})">{$vv.name}</li>
                              </foreach>
                           	</ul>
                         </div>
                      </div>
                      <div class="form-group">
                         <label class="col-sm-2 control-label">城市</label>
                         <div class="col-sm-2">
                           	<select class="small form-control" name="city_id" id="city_id{$k}">
                           		<option value="0">全省</option>
                           	</select>
                         </div>
                      </div>
                      <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">文章标题</label>
                        <div class="col-sm-8">
                          <input type="text" class="form-control" value="" name="title" id="title{$k}">
                        </div>
                      </div>
                      <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">文章副标题</label>
                        <div class="col-sm-8">
                          <input type="text" class="form-control" value="" placeholder="一般可置空" name="subtitle" id="subtitle{$k}">
                        </div>
                      </div>
                      <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">文章作者</label>
                        <div class="col-sm-8">
                          <input type="text" class="form-control" value="学历君" name="author" id="author{$k}">
                        </div>
                      </div>
                      <div class="form-group">
                        <label for="text" class="col-sm-2 control-label">置顶</label>
                        <div class="col-sm-5">
                          <div class="col-sm-2">
                             <label><input type="radio" name="top" value="0" checked="checked"> 普通 </label>
                          </div>
                          <div class="col-sm-3">
                             <label><input type="radio" name="top" value="1"> 列表置顶</label>
                          </div>
                          <div class="col-sm-3">
                             <label><input type="radio" name="top" value="2"> 栏目置顶</label>
                          </div>
                          <div class="col-sm-3">
                             <label><input type="radio" name="top" value="3"> 首页置顶</label>
                          </div>
                          <div class="col-sm-1">
                             <label><input type="text" name="position" value="0" placeholder="无特殊要求可不管"></label>
                          </div>
                        </div>
                      </div>
                      <div class="form-group">
                        <label for="text" class="col-sm-2 control-label">文章热度</label>
                        <div class="col-sm-5">
                          <div class="col-sm-2">
                             <label><input type="radio" name="hot" value="0" checked="checked"> 普通 </label>
                          </div>
                          <div class="col-sm-2">
                             <label><input type="radio" name="hot" value="1"> 推荐</label>
                          </div>
                          <div class="col-sm-3">
                             <label><input type="radio" name="hot" value="2"> 热门</label>
                          </div>
                        </div>
                      </div>
                      <div class="form-group">
                      	<label for="text" class="col-sm-2 control-label">banner图</label>
                      	<div class="col-sm-8"><input type="text" id="imagetext{$k}" name="thumb" value=""><input type="button" class="button" onClick="GetUploadify(1,'imagetext{$k}','article','')"  value="上传图片"/></div>
                      </div>
                      <div class="form-group">
                        <label for="text" class="col-sm-2 control-label">seo关键字</label>
                        <div class="col-sm-8">
                          <input type="text" class="form-control" name="keywords"  value="">
                        </div>
                      </div>
                      <div class="form-group">
                        <label for="text" class="col-sm-2 control-label">外部链接</label>
                        <div class="col-sm-8">
                          <input type="text" class="form-control" name="url"  placeholder="没有特殊需求不必填写">
                        </div>
                      </div>
                      <div class="form-group">
                        <label for="text" class="col-sm-2 control-label">文章排序</label>
                        <div class="col-sm-8">
                          <input type="text" class="form-control" name="order"  placeholder="没有特殊需求不必填写">
                        </div>
                      </div>
                      <div class="form-group">
                        <label for="text" class="col-sm-2 control-label">发布时间</label>
                        <div class="col-sm-8">
                              <div class="input-prepend input-group">
                                      <span class="add-on input-group-addon">
                                              <i class="glyphicon glyphicon-calendar fa fa-calendar">
                                              </i>
                                      </span>
                                  <input type="text" class="form-control" id ="publish_time{$k}" name="publish_time"  value="{$time|date="Y-m-d",###}">
                              </div>
                        </div>
                      </div>
                      <div class="form-group">
                        <label for="text" class="col-sm-2 control-label">是否显示</label>
                        <div class="col-sm-5">
                          <div class="col-sm-2">
                             <label><input type="radio" name="display" value="1" checked="checked"> 显示 </label>
                          </div>
                           <div class="col-sm-3">
                             <label><input type="radio" name="display" value="0"> 不显示</label>
                          </div>
                        </div>
                      </div>
                      <div class="form-group">
  	                    <label class="control-label col-sm-2">网页描述</label>
  	                    <div class="col-sm-8">
  				                    <textarea class="form-control" id="post_description{$k}" name="description"></textarea>
  	                    </div>
                      </div>
                      <div class="form-group">
  	                    <label class="control-label col-sm-2">文章内容</label>
  	                    <div class="col-sm-8">
          				        <textarea class="span12 ckeditor" id="post_content{$k}" name="content">
          				        </textarea>
  	                    </div>
                      </div>
                      <div class="form-group">
  	                    <label class="control-label col-sm-2">文章概述</label>
  	                    <div class="col-sm-8">
  				                    <textarea class="form-control" id="post_introduction{$k}" name="introduction"></textarea>
        				              <input type="button" id="get_introduction{$k}" value="获取概述"/>
  	                    </div>
                      </div>
                      <div class="form-group">
                      	<label class="control-label col-sm-2">
                      		<input type="hidden" name="first_column_id" value="{$v.first_column_id}">
  	                  	 	<input type="hidden" name="second_column_id" value="{$v.second_column_id}">
                          <input type="hidden" name="third_column_id" value="{$v.third_column_id}">
                          <input type="hidden" name="fourth_column_id" value="{$v.id}">
                          <input type="hidden" name="act" value="add">
                          <input type="hidden" name="doer" value="{$admin_info.user_name}">
                        </label>
                      	<div class="col-sm-8">
                      	  	<button type="button"  onclick="checkForm{$k}()" class="btn btn-info pull-right">提交</button>
                      	</div>
                      </div>
                    </div>
                    <div class="box-footer row">

                    </div>
                  </form>
                </div>

            </div>
  	   </div>
  	</section>
  </div>

  <script type="text/javascript">
      var editor;
      $(function () {
          //具体参数配置在  editor_config.js 中
          var options = {
              zIndex: 999,
              initialFrameWidth: "100%", //初化宽度
              initialFrameHeight: 400, //初化高度
              focus: false, //初始化时，是否让编辑器获得焦点true或false
              maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',//允许的最大字符数 'fullscreen',
              pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
              autoHeightEnabled: true,
              indent: true,               // 行首缩进
              indentValue: '2em'           //行首缩进的大小
           /*   autotypeset: {
                  mergeEmptyline: true,        //合并空行
                  removeClass: true,           //去掉冗余的class
                  removeEmptyline: false,      //去掉空行
                  textAlign: "left",           //段落的排版方式，可以是 left,right,center,justify 去掉这个属性表示不执行排版
                  imageBlockLine: 'center',    //图片的浮动方式，独占一行剧中,左右浮动，默认: center,left,right,none 去掉这个属性表示不执行排版
                  pasteFilter: false,          //根据规则过滤没事粘贴进来的内容
                  clearFontSize: false,        //去掉所有的内嵌字号，使用编辑器默认的字号
                  clearFontFamily: false,      //去掉所有的内嵌字体，使用编辑器默认的字体
                  removeEmptyNode: false,      //去掉空节点
                                               //可以去掉的标签
                  removeTagNames: {"font": 1},

              }*/
          };
          editor = new UE.ui.Editor(options);
          editor.render("post_content{$k}");
      });

  	$('#publish_time{$k}').daterangepicker({
  		format:"YYYY-MM-DD",
  		singleDatePicker: true,
  		showDropdowns: true,
  		minDate:'2016-01-01',
  		maxDate:'2030-01-01',
  		startDate:'{$info.publish_time|date="Y-m-d",###}',
  	    locale : {
              applyLabel : '确定',
              cancelLabel : '取消',
              fromLabel : '起始时间',
              toLabel : '结束时间',
              customRangeLabel : '自定义',
              daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
              monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
              firstDay : 1
          }
  	});

  	function checkForm{$k}(){
  		if($('#title{$k}').val() == ''){
  			alert("请填写文章标题！");
  			return false;
  		}
  		if($('#post_content{$k}').val() == ''){
  			alert("请填写文章内容！");
  			return false;
  		}
  		$('#add_post{$k}').submit();
  	}

  </script>
  <script>
  $(function(){
    $(".personqg").on("click",function(){
      $(".personsp").css("display","block");
    })
  })
  $(function(){
    $(".select").on("click",function(){
      $(".personsp").css("display","block");
    })
  })
  function get_city{$k}($i){
    $(".personno").css("display","none");
	$(".personqg").css("display","block");
	$(".personqg{$k}").css("display","none");
    $(".personno{$k}").eq($i).css("display","block");
    $("#province{$k}").val($i);
    $.ajax({
          type : "POST",
          url : "{:U('Overseas/add_article')}",
          data : {
              "province_id" : $i
          },
          success : function(res) {
             $("#city_id{$k}").empty();
             $("#city_id{$k}").append("<option value='0'>全省</option>");
             $jsonobj = eval('(' + res + ')');
             $.each($jsonobj, function (key, value) {

              $("#city_id{$k}").append("<option value='"+value.id+"'>"+value.name+"</option>");
             });
          }
      });
  }
  $(function(){
    $("#get_introduction{$k}").on("click",function(){
      $str1=$("#post_content{$k}").val();
      $str2=$str1.substring($str1.indexOf("<p"),$str1.indexOf('</p>')+4);
      $("#post_introduction{$k}").val($str2);
    })
  })
</script>
</foreach>
<script>
$(function(){
  setTimeout(function(){
    $(".tomeoutnone").css("display","none");
  },1000);
})

function tab_active($k){
  $(".tab_ul li").removeClass('active');
  $(".tab_ul li").eq($k+1).addClass('active');
  $(".wrapper").css("display","none");
  $(".wrapper").eq($k+1).css("display","block");
}
</script>
</body>
</html>
